<template>
    <base-container>
        <div style="background-color: white;padding: 10px 0">
            <data-image
                customStyle="height:300rpx;width:300rpx;margin-left:225rpx;border-radius:50%;background-color:transparent"
                update v-if="valueKey === 'tx'" v-model="formData[valueKey]"></data-image>
            <data-page-select v-else-if="valueKey === 'ssjg'"></data-page-select>
            <uni-easyinput v-else :inputBorder="false" :type="inputType" v-model="formData[valueKey]"
                :placeholder="`请输入${label}`">
            </uni-easyinput>
        </div>
        <div style="position: fixed;bottom: 100px;width:680rpx;margin: 40rpx;">
            <button type="primary" :disabled="!(formData[valueKey] && formData[valueKey].length > 0)"
                @tap="submit">提交</button>
        </div>
    </base-container>
</template>
<script setup lang="ts">
import { useUserStore } from '@/stores/modules/user';
import { onLoad } from '@dcloudio/uni-app';
import { ref } from 'vue';
import MyModelImp from '@/pages/my/model/MyModelImp';

const formData = ref(useUserStore().getUser)
const myModelImp = new MyModelImp();
const inputType = ref('text')
const valueKey = ref('')
let label = ref('')

const submit = () => {
    myModelImp.updateUserInfo({ id: formData.value.id, [valueKey.value]: formData.value[valueKey.value] })
}

onLoad(({ title, key }: any) => {
    label.value = title
    valueKey.value = key
    uni.setNavigationBarTitle({
        title: '设置' + title
    });
    if (key === 'yhmm') {
        inputType.value = 'password'
    } else if (key === 'yhdh') {
        inputType.value = 'number'
    }
})

</script>

<style lang="scss" scoped>

</style>